<template>
    <el-dropdown trigger="click" @command="command">
        <span>
            <user-head></user-head>
        </span>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>我的主页</el-dropdown-item>
            <el-dropdown-item command="logout">退出</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>
</template>

<script>
import UserHead from '../common/UserHead'

export default {
    name: 'user-icon',
    components: { UserHead },
    methods: {
        command(command) {
            command === 'logout' ? this.$store.state.isLogin = true && this.$router.push('/home') : ''
        }
    }
}
</script>
